﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core;
using Cofe.Core.Logger;

namespace Cofe.Data
{
    [Export(typeof(ICofeService))]
    [ServicePriority(ServicePriorityAttribute.DefaultPriority_COFEDB)]
    public class EFCofeSystemEventConfig : IDatabaseConfigurator
    {
        public void OnDatabaseCreating(CofeDbContext context)
        {
     
        }

        public void OnModelCreating(DbModelBuilder modelBuilder)
        { 
            var logConfig = modelBuilder.Entity<CofeSystemEventLog>();
            logConfig.ToTable("CofeSystemEvents");
            logConfig.Property(o => o.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            logConfig.Property(o => o.EntryId).IsOptional();
        }
    }
}
